package com.qidian.buy.sso.controller;

import com.qidian.buy.entity.User;
import com.qidian.buy.sso.service.IUserService;
import com.qidian.buy.util.pojo.BuyResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author 戴着假发的程序员
 * @since 2023-05-18
 */
@RestController
@RequestMapping("/buy/user")
@CrossOrigin
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/reg")
    public BuyResult reg(User user){
        return userService.saveUser(user);
    }
    @PostMapping("/login")
    public BuyResult login(String username,String password){
        return userService.login(username,password);
    };

    @GetMapping("/checkLogin")
    public BuyResult<User> checkLogin(String token){
        return userService.checkLogin(token);
    }
}
